home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 332_01 / curses.h < prev    next >
C/C++ Source or Header  |  1990-01-05  |  14KB  |  286 lines

  1. /****************************************************************/
  2. /*                CURSES.H                */
  3. /* Header file for definitions and declarations for the        */
  4. /* PCcurses package. This should be #include'd in all user    */
  5. /* programs.                            */
  6. /****************************************************************/
  7. /* This version of curses is based on ncurses, a curses version    */
  8. /* originally written by Pavel Curtis at Cornell University.    */
  9. /* I have made substantial changes to make it run on IBM PC's,    */
  10. /* and therefore consider myself free to make it public domain.    */
  11. /*                Bjorn Larsson (bl@infovox.se)    */
  12. /****************************************************************/
  13. /* 1.4:  Window origin mod in overlay() and overwrite(),    */
  14. /*     on public (and very reasonable) request. Swapped    */
  15. /*     #define'd values of OK and ERR; OK now 1, and        */
  16. /*     ERR is 0/NULL. Conforms better to UNIX versions.    */
  17. /*     borderchars[] removed from WINDOW struct since        */
  18. /*     the border() functions were re-defined. Use of        */
  19. /*     short wherever possible. Portability improve-        */
  20. /*     ments, mispelled name of [w]setscrreg():    900114    */
  21. /* 1.3:     All modules lint-checked with MSC '-W3' and        */
  22. /*     Turbo'C' '-w -w-pro' switches. Support for        */
  23. /*     border(), wborder() functions:            881005    */
  24. /* 1.2:     Rcsid[] string in all modules, for mainte-        */
  25. /*     nance:                        881002    */
  26. /* 1.1:     'Raw' output routines, revision info in        */
  27. /*     curses.h:                    880306    */
  28. /* 1.0:     Release:                    870515    */
  29. /****************************************************************/
  30.  
  31. /* general definitions */
  32.  
  33. #ifndef     bool
  34. #define  bool        char        /* boolean type */
  35. #endif
  36.  
  37. #ifndef     TRUE
  38. #define     TRUE        1        /* booleans */
  39. #endif
  40.  
  41. #ifndef     FALSE
  42. #define     FALSE        0
  43. #endif
  44.  
  45. #define     ERR        0        /* general error flag */
  46. #define     OK        1        /* general OK flag */
  47.  
  48. /* functions defined as macros */
  49.  
  50. #define getch()       wgetch(stdscr)    /* using macroes allows you to use */
  51. #define    ungetch(c) wungetch(c)        /* #undef getch/ungetch in your */
  52.                     /* programs to use MSC/TRC getch() */
  53.                     /* and ungetch() routines */
  54.  
  55. #define getyx(win,y,x)       (y = (win)->_cury, x = (win)->_curx)
  56.  
  57. #ifndef max
  58. #define max(a,b) (((a) > (b)) ? (a) : (b))
  59. #endif
  60. #ifndef min
  61. #define min(a,b) (((a) < (b)) ? (a) : (b))
  62. #endif
  63.  
  64. /* video attribute definitions. Colour definitions for */
  65. /* CGA/EGA should also go here... */
  66.  
  67. #define    A_ALTCHARSET   0
  68. #define    A_BLINK        0x100
  69. #define    A_BLANK        0x200
  70. #define    A_BOLD         0x400
  71. #define    A_DIM          0
  72. #define    A_PROTECT      0
  73. #define    A_REVERSE      0x800
  74. #define    A_STANDOUT     0x1000
  75. #define    A_UNDERLINE    0x2000
  76.  
  77. /* function and keypad key definitions. Many are just for compatibility */
  78.  
  79. #define KEY_BREAK      0x101        /* Not on PC */
  80. #define KEY_DOWN       0x102        /* The four arrow keys */
  81. #define KEY_UP         0x103
  82. #define KEY_LEFT       0x104
  83. #define KEY_RIGHT      0x105
  84. #define KEY_HOME       0x106        /* Home key */
  85. #define KEY_BACKSPACE  0x107        /* Not on PC */
  86. #define KEY_F0         0x108        /* Function keys. Space for */
  87. #define KEY_F(n)       (KEY_F0+(n)) /*  64 keys is reserved. */
  88. #define KEY_DL         0x148        /* Not on PC */
  89. #define KEY_IL         0x149        /* Insert line */
  90. #define KEY_DC         0x14a        /* Delete character */
  91. #define KEY_IC         0x14b        /* Insert char or enter insert mode */
  92. #define KEY_EIC        0x14c        /* Exit insert char mode */
  93. #define KEY_CLEAR      0x14d        /* Clear screen */
  94. #define KEY_EOS        0x14e        /* Clear to end of screen */
  95. #define KEY_EOL        0x14f        /* Clear to end of line */
  96. #define KEY_SF         0x150        /* Scroll 1 line forward */
  97. #define KEY_SR         0x151        /* Scroll 1 line backwards (reverse) */
  98. #define KEY_NPAGE      0x152        /* Next page */
  99. #define KEY_PPAGE      0x153        /* Previous page */
  100. #define KEY_STAB       0x154        /* Set tab */
  101. #define KEY_CTAB       0x155        /* Clear tab */
  102. #define KEY_CATAB      0x156        /* Clear all tabs */
  103. #define KEY_ENTER      0x157        /* Enter or send (unreliable) */
  104. #define KEY_SRESET     0x158        /* soft (partial) reset (unreliable) */
  105. #define KEY_RESET      0x159        /* reset or hard reset (unreliable) */
  106. #define KEY_PRINT      0x15a        /* print or copy */
  107. #define KEY_LL         0x15b        /* home down or bottom (lower left) */
  108. #define KEY_ABORT      0x15c        /*  Abort/Terminate key (any) */
  109. #define KEY_SHELP      0x15d        /* Short help */
  110. #define KEY_LHELP      0x15e        /* Long help */
  111.  
  112. /* type declarations */
  113.  
  114. typedef struct
  115.   {
  116.   short       _cury;            /* Current pseudo-cursor */
  117.   short       _curx;
  118.   short       _maxy;            /* Max coordinates */
  119.   short       _maxx;
  120.   short       _begy;            /* Origin on screen */
  121.   short       _begx;
  122.   short       _flags;            /* Window properties */
  123.   short       _attrs;            /* Attributes of written characters */
  124.   short       _tabsize;            /* Tab character size */
  125.   bool       _clear;            /* Causes clear at next refresh */
  126.   bool       _leave;            /* Leaves cursor as it happens */
  127.   bool       _scroll;            /* Allows window scrolling */
  128.   bool       _nodelay;            /* Input character wait flag */
  129.   bool       _keypad;            /* Flags keypad key mode active */
  130.   short   **_line;            /* Pointer to line pointer array */
  131.   short      *_minchng;            /* First changed character in line */
  132.   short      *_maxchng;            /* Last changed character in line */
  133.   short       _regtop;            /* Top of scrolling region */
  134.   short       _regbottom;            /* Bottom of scrolling region */
  135.   }    WINDOW;
  136.  
  137. /* External variables */
  138.  
  139. extern    int    LINES;            /* terminal height */
  140. extern    int    COLS;            /* terminal width */
  141. extern    WINDOW *curscr;            /* the current screen image */
  142. extern    WINDOW *stdscr;            /* the default screen window */
  143.  
  144. /* PCcurses function declarations */
  145.  
  146. extern    int     addch();        /* put char in stdscr */
  147. extern    int     addrawch();        /* put char in stdscr, raw */
  148. extern    int     addstr();        /* put string in stdscr */
  149. extern    void     attrset();        /* set stdscr char attributes */
  150. extern    void     attroff();        /* clear attribute(a) stdscr */
  151. extern    void     attron();        /* add attribute(s) stdscr */
  152. extern    int     baudrate();        /* compatibility dummy */
  153. extern    void     beep();        /* sound bell */
  154. extern    void     border();        /* Set non-std box characters */
  155. extern    void     box();            /* draw a box around a window */
  156. extern    void     cbreak();        /* set terminal cbreak mode */
  157. extern    void     clear();        /* clear stdscr */
  158. extern    void     clearok();        /* marks a window for screen clear */
  159. extern    int     clrtobot();        /* clear end of stdscr */
  160. extern    int     clrtoeol();        /* clear end of line in stdscr */
  161. extern    void     crmode();        /* set terminal cbreak mode */
  162. extern    void     cursoff();        /* turns off hardware cursor */
  163. extern    void     curson();        /* turns on hardware cursor */
  164. extern    void     def_prog_mode();    /* save TTY modes */
  165. extern    void     def_shell_mode();    /* compatibility dummy */
  166. extern    int     delch();        /* delete a char in stdscr */
  167. extern    int     deleteln();        /* delete a line in stdscr */
  168. extern    void     delwin();        /* delete a window or a subwindow */
  169. extern  void     doupdate();        /* update physical screen */
  170. extern    void     echo();        /* set terminal echo mode */
  171. extern    int     endwin();        /* cleanup and finitialization */
  172. extern    void     erase();        /* erase stdscr */
  173. extern    int     erasechar();        /* return char kill character */
  174. extern    int     fixterm();        /* compatibility dummy */
  175. extern    void     flash();        /* flash terminal screen */
  176. extern    void     flushinp();        /* kill pending keyboard input */
  177. extern  int     getstr();        /* get string to stdscr and buffer */
  178. extern    int     gettmode();        /* compatibility dummy */
  179. extern    void     idlok();        /* use ins/del line (dummy) */
  180. extern    int     initscr();        /* curses initialization */
  181. extern  int     inch();        /* get char at stdscr cursor */
  182. extern    int     insch();        /* insert character in stdscr */
  183. extern    int     insrawch();        /* insert character in stdscr, raw */
  184. extern    int     insertln();        /* insert new line in stdscr */
  185. extern    void     keypad();        /* marks a window for keypad usage */
  186. extern    int     killchar();        /* return line kill character */
  187. extern    char    *longname();        /* terminal de